package com.demo.factory.usefactory_02;

public class ValidatorFactory {

    public Validator getValidator(String type) {
        if (type == null) {
            return null;
        }
        if ("A".equalsIgnoreCase(type)) {
            return new ConcreteValidatorA();
        } else if ("B".equalsIgnoreCase(type)) {
            return new ConcreteValidatorB();
        }
        // 可以抛出异常或者返回null
        return null;
    }
}
